home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / ExtUtils / MM_Win32.pm < prev    next >
Text File  |  1999-01-25  |  23KB  |  824 lines

  1. package ExtUtils::MM_Win32;
  2.  
  3. =head1 NAME
  4.  
  5. ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.  use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
  10.  
  11. =head1 DESCRIPTION
  12.  
  13. See ExtUtils::MM_Unix for a documentation of the methods provided
  14. there. This package overrides the implementation of these methods, not
  15. the semantics.
  16.  
  17. =over
  18.  
  19. =cut 
  20.  
  21. use Config;
  22. #use Cwd;
  23. use File::Basename;
  24. require Exporter;
  25.  
  26. Exporter::import('ExtUtils::MakeMaker',
  27.        qw( $Verbose &neatvalue));
  28.  
  29. $ENV{EMXSHELL} = 'sh'; # to run `commands`
  30. unshift @MM::ISA, 'ExtUtils::MM_Win32';
  31.  
  32. $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
  33. $GCC     = 1 if $Config{'cc'} =~ /^gcc/i;
  34. $DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
  35. $NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
  36. $OBJ   = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
  37.  
  38. sub dlsyms {
  39.     my($self,%attribs) = @_;
  40.  
  41.     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  42.     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  43.     my($imports)  = $attribs{IMPORTS} || $self->{IMPORTS} || {};
  44.     my(@m);
  45.     (my $boot = $self->{NAME}) =~ s/:/_/g;
  46.  
  47.     if (not $self->{SKIPHASH}{'dynamic'}) {
  48.     push(@m,"
  49. $self->{BASEEXT}.def: Makefile.PL
  50. ",
  51.      q!    $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\
  52.      -e "Mksymlists('NAME' => '!, $self->{NAME},
  53.      q!', 'DLBASE' => '!,$self->{DLBASE},
  54.      q!', 'DL_FUNCS' => !,neatvalue($funcs),
  55.      q!, 'IMPORTS' => !,neatvalue($imports),
  56.      q!, 'DL_VARS' => !, neatvalue($vars), q!);"
  57. !);
  58.     }
  59.     join('',@m);
  60. }
  61.  
  62. sub replace_manpage_separator {
  63.     my($self,$man) = @_;
  64.     $man =~ s,/+,.,g;
  65.     $man;
  66. }
  67.  
  68. sub maybe_command {
  69.     my($self,$file) = @_;
  70.     my @e = exists($ENV{'PATHEXT'})
  71.           ? split(/;/, $ENV{PATHEXT})
  72.       : qw(.com .exe .bat .cmd);
  73.     my $e = '';
  74.     for (@e) { $e .= "\Q$_\E|" }
  75.     chop $e;
  76.     # see if file ends in one of the known extensions
  77.     if ($file =~ /($e)$/i) {
  78.     return $file if -e $file;
  79.     }
  80.     else {
  81.     for (@e) {
  82.         return "$file$_" if -e "$file$_";
  83.     }
  84.     }
  85.     return;
  86. }
  87.  
  88. sub file_name_is_absolute {
  89.     my($self,$file) = @_;
  90.     $file =~ m{^([a-z]:)?[\\/]}i ;
  91. }
  92.  
  93. sub find_perl {
  94.     my($self, $ver, $names, $dirs, $trace) = @_;
  95.     my($name, $dir);
  96.     if ($trace >= 2){
  97.     print "Looking for perl $ver by these names:
  98. @$names
  99. in these dirs:
  100. @$dirs
  101. ";
  102.     }
  103.     foreach $dir (@$dirs){
  104.     next unless defined $dir; # $self->{PERL_SRC} may be undefined
  105.     foreach $name (@$names){
  106.         my ($abs, $val);
  107.         if ($self->file_name_is_absolute($name)) { # /foo/bar
  108.         $abs = $name;
  109.         } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
  110.         $abs = $self->catfile($dir, $name);
  111.         } else { # foo/bar
  112.         $abs = $self->canonpath($self->catfile($self->curdir, $name));
  113.         }
  114.         print "Checking $abs\n" if ($trace >= 2);
  115.         next unless $self->maybe_command($abs);
  116.         print "Executing $abs\n" if ($trace >= 2);
  117.         $val = `$abs -e "require $ver;" 2>&1`;
  118.         if ($? == 0) {
  119.             print "Using PERL=$abs\n" if $trace;
  120.             return $abs;
  121.         } elsif ($trace >= 2) {
  122.         print "Result: `$val'\n";
  123.         }
  124.     }
  125.     }
  126.     print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  127.     0; # false and not empty
  128. }
  129.  
  130. sub catdir {
  131.     my $self = shift;
  132.     my @args = @_;
  133.     for (@args) {
  134.     # append a slash to each argument unless it has one there
  135.     $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\";
  136.     }
  137.     my $result = $self->canonpath(join('', @args));
  138.     $result;
  139. }
  140.  
  141. =item catfile
  142.  
  143. Concatenate one or more directory names and a filename to form a
  144. complete path ending with a filename
  145.  
  146. =cut
  147.  
  148. sub catfile {
  149.     my $self = shift @_;
  150.     my $file = pop @_;
  151.     return $file unless @_;
  152.     my $dir = $self->catdir(@_);
  153.     $dir =~ s/(\\\.)$//;
  154.     $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\";
  155.     return $dir.$file;
  156. }
  157.  
  158. sub init_others
  159. {
  160.  my ($self) = @_;
  161.  &ExtUtils::MM_Unix::init_others;
  162.  $self->{'TOUCH'}  = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e touch';
  163.  $self->{'CHMOD'}  = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e chmod'; 
  164.  $self->{'CP'}     = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e cp';
  165.  $self->{'RM_F'}   = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_f';
  166.  $self->{'RM_RF'}  = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_rf';
  167.  $self->{'MV'}     = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mv';
  168.  $self->{'NOOP'}   = 'rem';
  169.  $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f';
  170.  $self->{'LD'}     = $Config{'ld'} || 'link';
  171.  $self->{'AR'}     = $Config{'ar'} || 'lib';
  172.  $self->{'LDLOADLIBS'} ||= $Config{'libs'};
  173.  # -Lfoo must come first for Borland, so we put it in LDDLFLAGS
  174.  if ($BORLAND) {
  175.      my $libs = $self->{'LDLOADLIBS'};
  176.      my $libpath = '';
  177.      while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
  178.          $libpath .= ' ' if length $libpath;
  179.          $libpath .= $1;
  180.      }
  181.      $self->{'LDLOADLIBS'} = $libs;
  182.      $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'};
  183.      $self->{'LDDLFLAGS'} .= " $libpath";
  184.  }
  185.  $self->{'DEV_NULL'} = '> NUL';
  186.  # $self->{'NOECHO'} = ''; # till we have it working
  187. }
  188.  
  189.  
  190. =item constants (o)
  191.  
  192. Initializes lots of constants and .SUFFIXES and .PHONY
  193.  
  194. =cut
  195.  
  196. sub constants {
  197.     my($self) = @_;
  198.     my(@m,$tmp);
  199.  
  200.     for $tmp (qw/
  201.  
  202.           AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
  203.           VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
  204.           INST_ARCHLIB INST_SCRIPT PREFIX  INSTALLDIRS
  205.           INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
  206.           INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
  207.           PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
  208.           FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
  209.           PERL_INC PERL FULLPERL
  210.  
  211.           / ) {
  212.     next unless defined $self->{$tmp};
  213.     push @m, "$tmp = $self->{$tmp}\n";
  214.     }
  215.  
  216.     push @m, qq{
  217. VERSION_MACRO = VERSION
  218. DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
  219. XS_VERSION_MACRO = XS_VERSION
  220. XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
  221. };
  222.  
  223.     push @m, qq{
  224. MAKEMAKER = $INC{'ExtUtils\MakeMaker.pm'}
  225. MM_VERSION = $ExtUtils::MakeMaker::VERSION
  226. };
  227.  
  228.     push @m, q{
  229. # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
  230. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
  231. # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)  !!! Deprecated from MM 5.32  !!!
  232. # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
  233. # DLBASE  = Basename part of dynamic library. May be just equal BASEEXT.
  234. };
  235.  
  236.     for $tmp (qw/
  237.           FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
  238.           LDFROM LINKTYPE
  239.           /    ) {
  240.     next unless defined $self->{$tmp};
  241.     push @m, "$tmp = $self->{$tmp}\n";
  242.     }
  243.  
  244.     push @m, "
  245. # Handy lists of source code files:
  246. XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
  247. C_FILES = ".join(" \\\n\t", @{$self->{C}})."
  248. O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
  249. H_FILES = ".join(" \\\n\t", @{$self->{H}})."
  250. MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
  251. MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
  252. ";
  253.  
  254.     for $tmp (qw/
  255.           INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
  256.           /) {
  257.     next unless defined $self->{$tmp};
  258.     push @m, "$tmp = $self->{$tmp}\n";
  259.     }
  260.  
  261.     push @m, qq{
  262. .USESHELL :
  263. } if $DMAKE;
  264.  
  265.     push @m, q{
  266. .NO_CONFIG_REC: Makefile
  267. } if $ENV{CLEARCASE_ROOT};
  268.  
  269.     # why not q{} ? -- emacs
  270.     push @m, qq{
  271. # work around a famous dec-osf make(1) feature(?):
  272. makemakerdflt: all
  273.  
  274. .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
  275.  
  276. # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
  277. # some make implementations will delete the Makefile when we rebuild it. Because
  278. # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
  279. # does so. Our milage may vary.
  280. # .PRECIOUS: Makefile    # seems to be not necessary anymore
  281.  
  282. .PHONY: all config static dynamic test linkext manifest
  283.  
  284. # Where is the Config information that we are using/depend on
  285. CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
  286. };
  287.  
  288.     my @parentdir = split(/::/, $self->{PARENT_NAME});
  289.     push @m, q{
  290. # Where to put things:
  291. INST_LIBDIR      = }. $self->catdir('$(INST_LIB)',@parentdir)        .q{
  292. INST_ARCHLIBDIR  = }. $self->catdir('$(INST_ARCHLIB)',@parentdir)    .q{
  293.  
  294. INST_AUTODIR     = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)')       .q{
  295. INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)')   .q{
  296. };
  297.  
  298.     if ($self->has_link_code()) {
  299.     push @m, '
  300. INST_STATIC  = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
  301. INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
  302. INST_BOOT    = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
  303. ';
  304.     } else {
  305.     push @m, '
  306. INST_STATIC  =
  307. INST_DYNAMIC =
  308. INST_BOOT    =
  309. ';
  310.     }
  311.  
  312.     $tmp = $self->export_list;
  313.     push @m, "
  314. EXPORT_LIST = $tmp
  315. ";
  316.     $tmp = $self->perl_archive;
  317.     push @m, "
  318. PERL_ARCHIVE = $tmp
  319. ";
  320.  
  321. #    push @m, q{
  322. #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
  323. #
  324. #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
  325. #};
  326.  
  327.     push @m, q{
  328. TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
  329.  
  330. PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
  331. };
  332.  
  333.     join('',@m);
  334. }
  335.  
  336.  
  337. sub path {
  338.     local $^W = 1;
  339.     my($self) = @_;
  340.     my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'};
  341.     my @path = split(';',$path);
  342.     foreach(@path) { $_ = '.' if $_ eq '' }
  343.     @path;
  344. }
  345.  
  346. =item static_lib (o)
  347.  
  348. Defines how to produce the *.a (or equivalent) files.
  349.  
  350. =cut
  351.  
  352. sub static_lib {
  353.     my($self) = @_;
  354. # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
  355. #    return '' unless $self->needs_linking(); #might be because of a subdir
  356.  
  357.     return '' unless $self->has_link_code;
  358.  
  359.     my(@m);
  360.     push(@m, <<'END');
  361. $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
  362.     $(RM_RF) $@
  363. END
  364.     # If this extension has it's own library (eg SDBM_File)
  365.     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  366.     push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
  367.  
  368.     push @m,
  369. q{    $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
  370.               : ($GCC ? '-ru $@ $(OBJECT)'
  371.                       : '-out:$@ $(OBJECT)')).q{
  372.     }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
  373.     $(CHMOD) 755 $@
  374. };
  375.  
  376. # Old mechanism - still available:
  377.  
  378.     push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
  379.     if $self->{PERL_SRC};
  380.  
  381.     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  382.     join('', "\n",@m);
  383. }
  384.  
  385. =item dynamic_bs (o)
  386.  
  387. Defines targets for bootstrap files.
  388.  
  389. =cut
  390.  
  391. sub dynamic_bs {
  392.     my($self, %attribs) = @_;
  393.     return '
  394. BOOTSTRAP =
  395. ' unless $self->has_link_code();
  396.  
  397.     return '
  398. BOOTSTRAP = '."$self->{BASEEXT}.bs".'
  399.  
  400. # As Mkbootstrap might not write a file (if none is required)
  401. # we use touch to prevent make continually trying to remake it.
  402. # The DynaLoader only reads a non-empty file.
  403. $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists
  404.     '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
  405.     '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
  406.         -MExtUtils::Mkbootstrap \
  407.         -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
  408.     '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
  409.     $(CHMOD) 644 $@
  410.  
  411. $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
  412.     '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
  413.     -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
  414.     $(CHMOD) 644 $@
  415. ';
  416. }
  417.  
  418. =item dynamic_lib (o)
  419.  
  420. Defines how to produce the *.so (or equivalent) files.
  421.  
  422. =cut
  423.  
  424. sub dynamic_lib {
  425.     my($self, %attribs) = @_;
  426.     return '' unless $self->needs_linking(); #might be because of a subdir
  427.  
  428.     return '' unless $self->has_link_code;
  429.  
  430.     my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
  431.     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
  432.     my($ldfrom) = '$(LDFROM)';
  433.     my(@m);
  434.     push(@m,'
  435. # This section creates the dynamically loadable $(INST_DYNAMIC)
  436. # from $(OBJECT) and possibly $(MYEXTLIB).
  437. OTHERLDFLAGS = '.$otherldflags.'
  438. INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
  439.  
  440. $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
  441. ');
  442.     if ($GCC) {
  443.       push(@m,  
  444.        q{    dlltool --def $(EXPORT_LIST) --output-exp dll.exp
  445.     $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
  446.     dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp
  447.     $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
  448.     } else {
  449.       push(@m, $BORLAND ?
  450.        q{    $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) $(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,),$(RESFILES)} :
  451.        q{    $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}
  452.     );
  453.     }
  454.     push @m, '
  455.     $(CHMOD) 755 $@
  456. ';
  457.  
  458.     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  459.     join('',@m);
  460. }
  461.  
  462. sub perl_archive
  463. {
  464.     my ($self) = @_;
  465.     if($OBJ) {
  466.         if ($self->{CAPI} eq 'TRUE') {
  467.             return '$(PERL_INC)\perlCAPI$(LIB_EXT)';
  468.         }
  469.     }
  470.     return '$(PERL_INC)\\'.$Config{'libperl'};
  471. }
  472.  
  473. sub export_list
  474. {
  475.  my ($self) = @_;
  476.  return "$self->{BASEEXT}.def";
  477. }
  478.  
  479. =item canonpath
  480.  
  481. No physical check on the filesystem, but a logical cleanup of a
  482. path. On UNIX eliminated successive slashes and successive "/.".
  483.  
  484. =cut
  485.  
  486. sub canonpath {
  487.     my($self,$path) = @_;
  488.     $path =~ s/^([a-z]:)/\u$1/;
  489.     $path =~ s|/|\\|g;
  490.     $path =~ s|(.)\\+|$1\\|g ;                     # xx////xx  -> xx/xx
  491.     $path =~ s|(\\\.)+\\|\\|g ;                    # xx/././xx -> xx/xx
  492.     $path =~ s|^(\.\\)+|| unless $path eq ".\\";   # ./xx      -> xx
  493.     $path =~ s|\\$|| 
  494.              unless $path =~ m#^([a-z]:)?\\#;      # xx/       -> xx
  495.     $path .= '.' if $path =~ m#\\$#;
  496.     $path;
  497. }
  498.  
  499. =item perl_script
  500.  
  501. Takes one argument, a file name, and returns the file name, if the
  502. argument is likely to be a perl script. On MM_Unix this is true for
  503. any ordinary, readable file.
  504.  
  505. =cut
  506.  
  507. sub perl_script {
  508.     my($self,$file) = @_;
  509.     return "$file.pl" if -r "$file.pl" && -f _;
  510.     return;
  511. }
  512.  
  513. =item pm_to_blib
  514.  
  515. Defines target that copies all files in the hash PM to their
  516. destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
  517.  
  518. =cut
  519.  
  520. sub pm_to_blib {
  521.     my $self = shift;
  522.     my($autodir) = $self->catdir('$(INST_LIB)','auto');
  523.     return q{
  524. pm_to_blib: $(TO_INST_PM)
  525.     }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
  526.     "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
  527.         -e "pm_to_blib(qw[ }.
  528.     ($NMAKE ? '<<pmfiles.dat'
  529.         : '$(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n)').
  530.     q{ ],'}.$autodir.q{')"
  531.     }. ($NMAKE ? q{
  532. $(PM_TO_BLIB)
  533. <<
  534.     } : '') . $self->{NOECHO}.q{$(TOUCH) $@
  535. };
  536. }
  537.  
  538. =item test_via_harness (o)
  539.  
  540. Helper method to write the test targets
  541.  
  542. =cut
  543.  
  544. sub test_via_harness {
  545.     my($self, $perl, $tests) = @_;
  546.     "\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n";
  547. }
  548.  
  549.  
  550. =item tool_autosplit (override)
  551.  
  552. Use Win32 quoting on command line.
  553.  
  554. =cut
  555.  
  556. sub tool_autosplit{
  557.     my($self, %attribs) = @_;
  558.     my($asl) = "";
  559.     $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
  560.     q{
  561. # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
  562. AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
  563. };
  564. }
  565.  
  566. =item tools_other (o)
  567.  
  568. Win32 overrides.
  569.  
  570. Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
  571. the Makefile. Also defines the perl programs MKPATH,
  572. WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
  573.  
  574. =cut
  575.  
  576. sub tools_other {
  577.     my($self) = shift;
  578.     my @m;
  579.     my $bin_sh = $Config{sh} || 'cmd /c';
  580.     push @m, qq{
  581. SHELL = $bin_sh
  582. } unless $DMAKE;  # dmake determines its own shell 
  583.  
  584.     for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
  585.     push @m, "$_ = $self->{$_}\n";
  586.     }
  587.  
  588.     push @m, q{
  589. # The following is a portable way to say mkdir -p
  590. # To see which directories are created, change the if 0 to if 1
  591. MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
  592.  
  593. # This helps us to minimize the effect of the .exists files A yet
  594. # better solution would be to have a stable file in the perl
  595. # distribution with a timestamp of zero. But this solution doesn't
  596. # need any changes to the core distribution and works with older perls
  597. EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
  598. };
  599.  
  600.  
  601.     return join "", @m if $self->{PARENT};
  602.  
  603.     push @m, q{
  604. # Here we warn users that an old packlist file was found somewhere,
  605. # and that they should call some uninstall routine
  606. WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\
  607. -e "print 'WARNING: I have found an old package in';" \\
  608. -e "print '    ', $$ARGV[0], '.';" \\
  609. -e "print 'Please make sure the two installations are not conflicting';"
  610.  
  611. UNINST=0
  612. VERBINST=1
  613.  
  614. MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
  615. -e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
  616.  
  617. DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
  618. -e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', shift, '>';" \
  619. -e "print '=over 4';" \
  620. -e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \
  621. -e "print '=back';"
  622.  
  623. UNINSTALL =   $(PERL) -MExtUtils::Install \
  624. -e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
  625. -e "print \" packlist above carefully.\n  There may be errors. Remove the\";" \
  626. -e "print \" appropriate files manually.\n  Sorry for the inconveniences.\n\""
  627. };
  628.  
  629.     return join "", @m;
  630. }
  631.  
  632. =item xs_o (o)
  633.  
  634. Defines suffix rules to go from XS to object files directly. This is
  635. only intended for broken make implementations.
  636.  
  637. =cut
  638.  
  639. sub xs_o {    # many makes are too dumb to use xs_c then c_o
  640.     my($self) = shift;
  641.     return ''
  642. }
  643.  
  644. =item top_targets (o)
  645.  
  646. Defines the targets all, subdirs, config, and O_FILES
  647.  
  648. =cut
  649.  
  650. sub top_targets {
  651. # --- Target Sections ---
  652.  
  653.     my($self) = shift;
  654.     my(@m);
  655.     push @m, '
  656. #all ::    config $(INST_PM) subdirs linkext manifypods
  657. ';
  658.  
  659.     push @m, '
  660. all :: pure_all manifypods
  661.     '.$self->{NOECHO}.'$(NOOP)
  662.       unless $self->{SKIPHASH}{'all'};
  663.     
  664.     push @m, '
  665. pure_all :: config pm_to_blib subdirs linkext
  666.     '.$self->{NOECHO}.'$(NOOP)
  667.  
  668. subdirs :: $(MYEXTLIB)
  669.     '.$self->{NOECHO}.'$(NOOP)
  670.  
  671. config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists
  672.     '.$self->{NOECHO}.'$(NOOP)
  673.  
  674. config :: $(INST_ARCHAUTODIR)\.exists
  675.     '.$self->{NOECHO}.'$(NOOP)
  676.  
  677. config :: $(INST_AUTODIR)\.exists
  678.     '.$self->{NOECHO}.'$(NOOP)
  679. ';
  680.  
  681.     push @m, qq{
  682. config :: Version_check
  683.     $self->{NOECHO}\$(NOOP)
  684.  
  685. } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
  686.  
  687.     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
  688.  
  689.     if (%{$self->{MAN1PODS}}) {
  690.     push @m, qq[
  691. config :: \$(INST_MAN1DIR)\\.exists
  692.     $self->{NOECHO}\$(NOOP)
  693.  
  694. ];
  695.     push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
  696.     }
  697.     if (%{$self->{MAN3PODS}}) {
  698.     push @m, qq[
  699. config :: \$(INST_MAN3DIR)\\.exists
  700.     $self->{NOECHO}\$(NOOP)
  701.  
  702. ];
  703.     push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
  704.     }
  705.  
  706.     push @m, '
  707. $(O_FILES): $(H_FILES)
  708. ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
  709.  
  710.     push @m, q{
  711. help:
  712.     perldoc ExtUtils::MakeMaker
  713. };
  714.  
  715.     push @m, q{
  716. Version_check:
  717.     }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  718.         -MExtUtils::MakeMaker=Version_check \
  719.         -e "Version_check('$(MM_VERSION)')"
  720. };
  721.  
  722.     join('',@m);
  723. }
  724.  
  725. =item manifypods (o)
  726.  
  727. We don't want manpage process.  XXX add pod2html support later.
  728.  
  729. =cut
  730.  
  731. sub manifypods {
  732.     my($self) = shift;
  733.     return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
  734. }
  735.  
  736. =item dist_ci (o)
  737.  
  738. Same as MM_Unix version (changes command-line quoting).
  739.  
  740. =cut
  741.  
  742. sub dist_ci {
  743.     my($self) = shift;
  744.     my @m;
  745.     push @m, q{
  746. ci :
  747.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
  748.         -e "@all = keys %{ maniread() };" \\
  749.         -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
  750.         -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
  751. };
  752.     join "", @m;
  753. }
  754.  
  755. =item dist_core (o)
  756.  
  757. Same as MM_Unix version (changes command-line quoting).
  758.  
  759. =cut
  760.  
  761. sub dist_core {
  762.     my($self) = shift;
  763.     my @m;
  764.     push @m, q{
  765. dist : $(DIST_DEFAULT)
  766.     }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \
  767.         -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
  768.  
  769. tardist : $(DISTVNAME).tar$(SUFFIX)
  770.  
  771. zipdist : $(DISTVNAME).zip
  772.  
  773. $(DISTVNAME).tar$(SUFFIX) : distdir
  774.     $(PREOP)
  775.     $(TO_UNIX)
  776.     $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
  777.     $(RM_RF) $(DISTVNAME)
  778.     $(COMPRESS) $(DISTVNAME).tar
  779.     $(POSTOP)
  780.  
  781. $(DISTVNAME).zip : distdir
  782.     $(PREOP)
  783.     $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
  784.     $(RM_RF) $(DISTVNAME)
  785.     $(POSTOP)
  786.  
  787. uutardist : $(DISTVNAME).tar$(SUFFIX)
  788.     uuencode $(DISTVNAME).tar$(SUFFIX) \\
  789.         $(DISTVNAME).tar$(SUFFIX) > \\
  790.         $(DISTVNAME).tar$(SUFFIX)_uu
  791.  
  792. shdist : distdir
  793.     $(PREOP)
  794.     $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
  795.     $(RM_RF) $(DISTVNAME)
  796.     $(POSTOP)
  797. };
  798.     join "", @m;
  799. }
  800.  
  801. =item pasthru (o)
  802.  
  803. Defines the string that is passed to recursive make calls in
  804. subdirectories.
  805.  
  806. =cut
  807.  
  808. sub pasthru {
  809.     my($self) = shift;
  810.     return "PASTHRU = " . ($NMAKE ? "-nologo" : "");
  811. }
  812.  
  813.  
  814.  
  815. 1;
  816. __END__
  817.  
  818. =back
  819.  
  820. =cut 
  821.  
  822.  
  823.